//
//  main.m
//  OC6_数组&集合课后作业练习2
//
//  Created by dllo on 15/10/31.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "Contact.h"
#import "ContactManager.h"

int main(int argc, const char * argv[]) {

    
    Contact *c1 = [[Contact alloc] initWithName:@"Djjj" sex:@"male" phonenum:@"1333333" address:@"西山" group:@"同学" age:22];
    Contact *c2 = [[Contact alloc] initWithName:@"Cjjj" sex:@"female" phonenum:@"1444444" address:@"马兰" group:@"朋友" age:55];
    Contact *c3 = [[Contact alloc] initWithName:@"Phhh" sex:@"male" phonenum:@"1444444" address:@"春柳" group:@"家人" age:77];
    Contact *c4 = [[Contact alloc] initWithName:@"Cyyy" sex:@"female" phonenum:@"1555555" address:@"南沙" group:@"同学" age:66];
    
    ContactManager *contactList = [[ContactManager alloc] init];
    
    
    
    // 3,添加联系人
    [contactList addPerson:c1];
    [contactList addPerson:c2];
    [contactList addPerson:c3];
    [contactList addPerson:c4];
    
// 4, 获取某个分组名称下所有联系人，并且按照姓名升序排列。
    
//    NSMutableArray *arr = [contactList sortByNameForKey:@"C"];
//    for (Contact *contact in arr) {
//        NSLog(@"%@ %@ %@ %@ %@ %ld", [contact name], [contact sex], [contact phonenum], [contact address], [contact group], [contact age]);
//    }
    
    // 5,从通讯录中根据电话号码搜索联系人。
    
//    NSMutableArray *arr = [NSMutableArray array];
//    arr = [contactList searchByPhonenum:@"1444444"];
//        for (Contact *contact in arr) {
//            NSLog(@"%@ %@ %@ %@ %@ %ld", [contact name], [contact sex], [contact phonenum], [contact address], [contact group], [contact age]);
//        }
    
    // 6, 获取所有女性的联系人，并且按照年龄的降序排列。
    
//    NSMutableArray *arr = [NSMutableArray array];
//    arr = [contactList sortByAgeForFemale];
//            for (Contact *contact in arr) {
//                NSLog(@"%@ %@ %@ %@ %@ %ld", [contact name], [contact sex], [contact phonenum], [contact address], [contact group], [contact age]);
//            }
    
    // 7,根据姓名删除某个联系人。
//    [contactList deleteByName:@"Cjjj"];
    
    
    // 8,删除某个分组的全部联系人。
    [contactList deleteByKey:@"C"];
    
    
    
    
    
    // 2,打印所有联系人
    [contactList infoAllContact];
    
    
    
    return 0;
}
